<?php if (!defined('THINK_PATH')) exit();?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>ECSHOP 管理中心 - 商品列表 </title>
<meta name="robots" c>
<meta http-equiv="Content-Type" c />
<link href="/smfs/Public/admin/css/general.css" rel="stylesheet" type="text/css" />
<link href="/smfs/Public/admin/css/main.css" rel="stylesheet" type="text/css" />

<script type="text/javascript" src="/smfs/Public/admin/js/x-layui.js"></script>
<link href="/smfs/Public/css/layui.css" rel="stylesheet" type="text/css" media="all"/>
<script type="text/javascript" src="/smfs/Public/layui.js"></script>

</head>
<body>

<h1>
<span class="action-span"><a href="<?php echo U('admin/goods/goodsadd');?>">添加新商品</a></span>
<span class="action-span1"><a href="#">商品列表</a></span>
<div style="clear:both"></div>
</h1>

<div class="form-div">
  <form action="" name="searchForm">
    <img src="/smfs/Public/admin/images/icon_search.gif" width="26" height="22" border="0" alt="SEARCH" />
    <!-- <select name="cat_id">
      <option value="0">所有分类</option>
      <option value="1" >手机类型</option>
      <option value="4" >&nbsp;&nbsp;&nbsp;&nbsp;3G手机</option>
      <option value="5" >&nbsp;&nbsp;&nbsp;&nbsp;双模手机</option>
      <option value="2" >&nbsp;&nbsp;&nbsp;&nbsp;CDMA手机</option>
      <option value="3" >&nbsp;&nbsp;&nbsp;&nbsp;GSM手机</option>
      <option value="12" >充值卡</option>
      <option value="14" >&nbsp;&nbsp;&nbsp;&nbsp;移动手机充值卡</option>
      <option value="15" >&nbsp;&nbsp;&nbsp;&nbsp;联通手机充值卡</option>
      <option value="13" >&nbsp;&nbsp;&nbsp;&nbsp;小灵通/固话充值卡</option>
      <option value="6" >手机配件</option>
      <option value="11" >&nbsp;&nbsp;&nbsp;&nbsp;读卡器和内存卡</option>
      <option value="7" >&nbsp;&nbsp;&nbsp;&nbsp;充电器</option>
      <option value="8" >&nbsp;&nbsp;&nbsp;&nbsp;耳机</option>
      <option value="9" >&nbsp;&nbsp;&nbsp;&nbsp;电池</option>
    </select>
    <select name="brand_id">
      <option value="0">所有品牌</option>
      <option value="1">诺基亚</option>
      <option value="10">金立</option>
      <option value="9">联想</option>
      <option value="8">LG</option>
      <option value="7">索爱</option>
      <option value="6">三星</option>
      <option value="5">夏新</option>
      <option value="4">飞利浦</option>
      <option value="3">多普达</option>
      <option value="2">摩托罗拉</option>
      <option value="11">  恒基伟业</option>
    </select>
    <select name="intro_type">
      <option value="0">全部</option>
      <option value="is_best">精品</option>
      <option value="is_new">新品</option>
      <option value="is_hot">热销</option>
      <option value="is_promote">特价</option>
      <option value="all_type">全部推荐</option>
    </select>
    <select name="suppliers_id">
      <option value="0">全部</option>
      <option value="1">北京供货商</option>
      <option value="2">上海供货商</option>
    </select>
    <select name="is_on_sale">
      <option value=''>全部</option>
      <option value="1">上架</option>
      <option value="0">下架</option>
    </select> -->
    关键字 <input type="text" name="keyword" placeholder="请输入商品ID/名称/类别" style="width: 150px;"><input type="submit" value=" 搜索 " class="button" />
  </form>
</div>
<form method="post" action="" name="listForm" >
<div class="list-div" id="listDiv">
<table cellpadding="3" cellspacing="1">
  <tr>
    全选：<input type="checkbox" name="a" value="">&nbsp;&nbsp;<a onclick="delAll()" style="border: 1px solid;"><i class="layui-icon">&#xe640;</i>批量回收</a>
    <th>
      <a href="#">商品ID</a><img src="/smfs/Public/admin/images/sort_desc.gif"/>    
    </th>
    <th><a href="#">商品名称</a></th>
    <th><a href="#">类别</a></th>
    <th><a href="#">描述</a></th>
    <th><a href="#">价格</a></th>
    <th><a href="#">新品</a></th>
    <th><a href="#">热销</a></th>
    <th><a href="#">上架</a></th>
    <th><a href="#">库存</a></th>
    <th><a href="#">添加时间</a></th>
    <th>操作</th>
  </tr>
  <?php foreach ($goods as $g) { ?>
  <tr style="border: 1px solid #fbf1f1;">
      <td style="border-right: 1px solid #f1f1f1;"><input type="checkbox" value="<?php echo ($g["goods_id"]); ?>" name="aa" class="son">【<?php echo ($g["goods_id"]); ?>】</td>
      <td align="center" style="border-right: 1px solid #f1f1f1;"><span ><?php echo ($g["goods_name"]); ?></span></td>
      <td align="center" style="border-right: 1px solid #f1f1f1;"><span ><?php echo res_catname($g['cat_id']); ?> <?php echo ($g["cat_name"]); ?></span></td>
      <td align="center" style="border-right: 1px solid #f1f1f1;"><span ><?php echo (mb_substr(strip_tags(htmlspecialchars_decode($g["goods_desc"])),0,15,'utf-8')); ?></span></td>
      <td align="center" style="border-right: 1px solid #f1f1f1;"><span ><?php echo ($g["shop_price"]); ?></span></td>

      <?php if ($g['is_new'] == 1) { ?>
        <td align="center" style="border-right: 1px solid #f1f1f1;"><img src="/smfs/Public/admin/images/yes.gif"  /></td>
      <?php } else { ?>
        <td align="center" style="border-right: 1px solid #f1f1f1;"><img src="/smfs/Public/admin/images/no.gif"  /></td>
      <?php } ?>
      
      <?php if ($g['is_hot'] == 1) { ?>
        <td align="center" style="border-right: 1px solid #f1f1f1;"><img src="/smfs/Public/admin/images/yes.gif"  /></td>
      <?php } else { ?>
        <td align="center" style="border-right: 1px solid #f1f1f1;"><img src="/smfs/Public/admin/images/no.gif"  /></td>
      <?php } ?>

      <?php if ($g['is_on_sale'] == 1) { ?>
        <td align="center" style="border-right: 1px solid #f1f1f1;"><img src="/smfs/Public/admin/images/yes.gif"  /></td>
      <?php } else { ?>
        <td align="center" style="border-right: 1px solid #f1f1f1;"><img src="/smfs/Public/admin/images/no.gif"  /></td>
      <?php } ?>

      <td align="center" style="border-right: 1px solid #f1f1f1;"><span ><?php echo ($g["goods_number"]); ?></span></td>
      <td align="center" style="border-right: 1px solid #f1f1f1;"><span ><?php echo date('Y-m-d H:i:s',$g['add_time']) ?></span></td>
      <td align="center">
        <a title="商品状态" href="javascript:;" onclick="start_edit('商品状态','<?php echo U('admin/goods/goodstart',array('goods_id'=>$g['goods_id']));?>','4','500','400')" >
        <img src="/smfs/Public/admin/images/icon_priv.gif"/></a>

        <a href="<?php echo U('admin/goods/goodsdit',array('goods_id'=>$g['goods_id']));?>" title="商品编辑"><img src="/smfs/Public/admin/images/icon_edit.gif"></a>

        <!-- <a href="#" title="复制"><img src="/smfs/Public/admin/images/icon_copy.gif" width="16" height="16"/></a> -->

        <a href="javascript:;" title="回收" onclick="admin_del(this,'<?php echo ($g["goods_id"]); ?>')" ><img src="/smfs/Public/admin/images/icon_trash.gif"/></a>

      </td>
  </tr>
  <?php } ?>
</table>
<style>
    .fenye{ margin-top: 20px;}
    .fenye div a,.fenye div span{display: inline-block;padding: 5px 15px;margin-right: -1px;border: 1px solid #1AA094;}
    .fenye div span{background: #1AA094;color: #fff;}
</style>
<table id="page-table" cellspacing="0">
  <tr>
    <td class="fenye" align="right" nowrap="true"><?php echo ($page); ?></td>
  </tr>
</table>
</div>
</form>

<div id="footer">
共执行 7 个查询，用时 0.112141 秒，Gzip 已禁用，内存占用 3.085 MB<br />
版权所有 &copy; 2005-2010 上海商派网络科技有限公司，并保留所有权利。
</div>

<script>
    layui.use(['laydate','element','laypage','layer'], function(){
        $ = layui.jquery;//jquery
      laydate = layui.laydate;//日期插件
      lement = layui.element();//面包导航
      laypage = layui.laypage;//分页
      layer = layui.layer;//弹出层

      //单击全选 单击取消
      $('input[name="a"]').click(function(){  
                  //alert(this.checked);  
                  if($(this).is(':checked')){  
                      $('input[name="aa"]').each(function(){  
                          //此处如果用attr，会出现第三次失效的情况  
                          $(this).prop("checked",true);  
                      });  
              }else{  
                  $('input[name="aa"]').each(function(){  
                          $(this).removeAttr("checked",false);  
                      });   
              }        
          });  
    });

    //批量放入回收站提交
     function delAll () {
        layer.confirm('确认要放入回收站吗？',function(index){
            //捉到所有被选中的
            var arr = new Array();
            var chenked=$(".son:checked").each(function(){
               arr.push($(this).val()); 
            })
            //发异步，把数据提交给php
            $.ajax({
                url: "<?php echo U('admin/goods/goodsdels');?>",//请求地址
                type: "post",//请求方式
                dataType: "json",//返回数据类型
                data: {arr:arr},//发送的参数
                })
                .done(function(response) {
                      if(response.error==1){
                         layer.msg(response.info ,{icon:6});
                         location.reload();
                      }else{
                         layer.msg(response.info ,{icon:5});
                      }
                  })
                .fail(function() {
                    alert("ajxs交互失败");
                })  

            return false;  
        });
     }

    //编辑
    function start_edit(title,url,id,w,h) {
        x_admin_show(title,url,w,h); 
    }

    /*删除*/
    function admin_del(obj,id){
        layer.confirm('确认要放入回收站吗？',function(index){
          //发异步删除数据
          goods_id = id;
          $.ajax({
              url: "<?php echo U('admin/goods/goodsdel');?>",//请求地址
              type: "post",//请求方式
              dataType: "json",//返回数据类型
              data: {goods_id:goods_id},//发送的参数
              })
              .done(function(response) {
                    if(response.error==1){
                      layer.msg(response.info ,{icon:6});
                      $(obj).parents("tr").remove();
                    }else{
                      layer.msg(response.info ,{icon:5});
                    }
                })
              .fail(function() {
                  alert("ajxs交互失败");
              })  
          return false;
        });
    }
</script>
</body>
</html>